package cn.appsys.service.backend;

import javax.annotation.Resource;

import org.aspectj.weaver.Lint;
import org.springframework.stereotype.Service;

import cn.appsys.dao.backenduser.BackendUserMapper;
import cn.appsys.pojo.BackendUser;

import java.util.List;

@Service
public class BackendUserServiceImpl implements BackendUserService {
    @Resource
    private BackendUserMapper mapper;

    @Override
    public BackendUser login(String userCode, String userPassword) throws Exception {
        // TODO Auto-generated method stub
        BackendUser user = null;
        user = mapper.getLoginUser(userCode);
        //匹配密码
        if (null != user) {
            if (!user.getUserPassword().equals(userPassword))
                user = null;
        }
        return user;
    }

    @Override
    public List<BackendUser> getBackendUserListBiz(BackendUser backendUser, int pageIndex, int pageSize) throws Exception {
        return mapper.getBackendUserList(backendUser, (pageIndex - 1) * pageSize, pageSize);
    }

    @Override
    public int getBackendUserCountBiz(BackendUser backendUser) throws Exception {
        return mapper.getBackendUserCount(backendUser);
    }

    @Override
    public BackendUser getByBackendUserIdBiz(int id) throws Exception {
        return mapper.getByBackendUserId(id);
    }

    @Override
    public int delByBackendUserIdBiz(int id) throws Exception {
        return mapper.delByBackendUserId(id);
    }

    @Override
    public int addBackendUserBiz(BackendUser backendUser) throws Exception {
        return mapper.addBackendUser(backendUser);
    }

    @Override
    public int updateBackendUserBiz(BackendUser backendUser) {
        return mapper.updateBackendUser(backendUser);
    }
}
